# encoding: utf-8
class CreateRolesUsersJoin < ActiveRecord::Migration
  def self.up
    create_table :roles_users, :id => false do |t|
      t.column :role_id, :integer
      t.column :user_id, :integer
      
      t.timestamps    
    end
    admin_user = User.create(
      :username => 'root',
      :realname => '郑炜宇',
      :password => 'letmebe',
      :email => 'zhengweiyu@gmail.com',
      :mobile => '13888450237',
      :enabled => true
    )
    admin_role = Role.find_by_name('Administrator')
    admin_user.roles << admin_role
  end

  def self.down
    drop_table :roles_users
  end
end
